<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");
$this_day = now();
$pattern_year = "%Y";
$str_year = mdate($pattern_year, $this_day);

for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year; $i > 1900; $i--) {
    $year_data[$i] = $i;
}
if (isset($error))
    echo $error;
?>
<?php
if ($gardient_data->num_rows() > 0) {
    $gardient = $gardient_data->row();
    $date_long = $gardient->dob;
    $gardient_id = $gardient->id;
    $pattern = "%Y-%m-%d";
    $str_date = mdate($pattern, $date_long);
}

echo $erreur;
?>
<?php
$image_path = './assets/avatar_gardient/thumbs/' . $gardient->avatar;
if ($gardient->avatar != '') {
    if (file_exists($image_path)) {
        $image_path = base_url() . 'assets/avatar_gardient/thumbs/' . $gardient->avatar;
    } else {
        $image_path = base_url() . 'assets/avatar_gardient/noimage.gif';
    }
} else {
    $image_path = base_url() . 'assets/avatar_gardient/noimage.gif';
}
?>
<div id="wrapper-content">

            <div class="titre_home" >INFORMATION DU GARDIEN</div>

        <?php echo form_open_multipart(base_url() . 'index.php/user/edit_profile' . '/' . $gardient_id ); ?>
         <?php if(validation_errors()!="") {?><div class="error_form"><?php echo validation_errors(); ?></div><?php } ?>
            <table align="center" class="list" width="95%" cellpadding="5px">
            <tr>
                <td>Identifiant:</td>
                <td>
                    <?php echo $gardient->gardient_name; ?> | 
                    <?php if($gardient->available == 1){?>
                    <a href="<?php echo site_url('user/set_unavailable_gardient') . '/' .  $gardient->id?>" style="color: blue;">Disponible</a>
                    <?php }else{?>
                    <a href="<?php echo site_url('user/set_available_gardient') . '/' .  $gardient->id?>" style="color: red;">Indisponible</a>
                    <?php }?>
                </td>
            </tr>
            <tr>
                <td>Nom:</td>
                <td><input name="first_name" type="text" value="<?php echo $gardient->first_name; ?>"/></td>
             
            </tr>
            <tr>
                <td>Prénom:</td>
                <td><input name="last_name" type="text" value="<?php echo $gardient->last_name; ?>"/></td>
              
            </tr>
            <tr>
                <td>Email:</td>
                <td><input name="email" type="text" value="<?php echo $gardient->email; ?>"/></td>
               
            </tr>
            <tr>
                <td rowspan="2">Image:</td>
                <td><img width="100px" src="<?php echo $image_path; ?>"></td>
            </tr>
            <tr>
                <td><input name="userfile" id="userfile" type="file" size="25"/></td>
            </tr>
            <tr>
                <td>Sexe</td>
                <td>
                    <?php
                    $gender = $gardient->gender;

                    $male = array(
                        'name' => 'gender',
                        'id' => 'rad_male',
                        'value' => 'm',
                        'checked' => $gender == 'm' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );
                    $female = array(
                        'name' => 'gender',
                        'id' => 'rad_female',
                        'value' => 'f',
                        'checked' => $gender == 'f' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );

                    echo 'Male' . form_radio($male);
                    echo 'Female' . form_radio($female, 'Female');
                    ?>
                </td>
            </tr>
            <tr>
                <td><label for="birthday">Date de naissance :</label></td>
                <td>
                    D : <?php echo form_dropdown('birth_date', $day_data, get_date_part($str_date, 'day'), 'id="day"'); ?>
                    M : <?php echo form_dropdown('birth_month', $dropdown_data, get_date_part($str_date, 'month'), 'id="month"'); ?>
                    Y : <?php echo form_dropdown('birth_year', $year_data, get_date_part($str_date, 'year'), 'id="year"'); ?>
                </td>
            </tr>
            <tr>
                <td>Téléphonr:</td>
                <td><input name="phone" type="text" value="<?php echo $gardient->phone; ?>"/></td>
                </tr>
            <tr>
                <td>Experience:</td>
                <td><input name="experience" type="text" value="<?php echo $gardient->experience; ?>"/></td>
        
            </tr>
            <tr>
                <td>Addresse:</td> <td><input name="address" type="text" value="<?php echo $gardient->address; ?>"/></td>
              
            </tr>
            <tr>
                <td></td><td><input type="submit" name="submit" value="Update Profile"/></td>
            </tr>
        </table>
        <?php echo form_close() ?>
    </div> 

